package com.fare.taluo.message;

import org.apache.commons.configuration.PropertiesConfiguration;
/**
 * Email配置属性对应类
 * @author xiangsf 2012-12-10
 *
 */
public class EmailMessageProperties {
	
	public final static String EMAIL_SERVER_SWITCH = "message.email.switch";
	public final static String EMAIL_SMTPSERVER = "message.email.smtpserver";
	public final static String EMAIL_SMTPUSER = "message.email.smtpuser";
	public final static String EMAIL_SMTPPWD = "message.email.smtppwd";
	public final static String EMAIL_CONTENT_TYPE = "message.email.content.type";
	public final static String EMAIL_CONTENT_CHARSET = "message.email.content.charset";
	public final static String EMAIL_SMTP_DEFAULT_TO_ADDRESS = "message.email.defaultToAddress";
	public final static String EMAIL_SMTP_DEFAULT_SEND_ADDRESS = "message.email.sendAddress";
	
	/**
	 * 邮件控制开关
	 */
	private boolean emailServerSwitch = false;
	/**
	 * 邮件服务器地址
	 */
	private String emailSmtpServer;
	/**
	 * 邮件登陆用户名
	 */
	private String emailSmtpUser;
	/**
	 * 邮件登陆密码
	 */
	private String emailSmtpPwd;
	/**
	 * 邮件发送内容格式
	 */
	private String emailContentType;
	/**
	 * 邮件发送内容编码
	 */
	private String emailContentCharset;
	/**
	 * 默认发送目标地址
	 */
	private String defaultToAddress;
	/**
	 * 默认的发送地址
	 */
	private String sendAddress;
	
	public EmailMessageProperties(){
		
	}
	
	public EmailMessageProperties(PropertiesConfiguration pc){
		setProperties(pc);
	}
	
	public void setProperties(PropertiesConfiguration pc){
		this.emailServerSwitch = pc.getBoolean(EMAIL_SERVER_SWITCH, false);
		this.emailSmtpServer = pc.getString(EMAIL_SMTPSERVER);
		this.emailSmtpUser = pc.getString(EMAIL_SMTPUSER);
		this.emailSmtpPwd = pc.getString(EMAIL_SMTPPWD);
		this.emailContentType = pc.getString(EMAIL_CONTENT_TYPE, "text/html");
		this.emailContentCharset = pc.getString(EMAIL_CONTENT_CHARSET, "gb2312");
		this.defaultToAddress = pc.getString(EMAIL_SMTP_DEFAULT_TO_ADDRESS);
		this.sendAddress = pc.getString(EMAIL_SMTP_DEFAULT_SEND_ADDRESS);
	}
	public boolean isEmailServerSwitch() {
		return emailServerSwitch;
	}
	public void setEmailServerSwitch(boolean emailServerSwitch) {
		this.emailServerSwitch = emailServerSwitch;
	}
	public String getEmailSmtpServer() {
		return emailSmtpServer;
	}
	public void setEmailSmtpServer(String emailSmtpServer) {
		this.emailSmtpServer = emailSmtpServer;
	}
	public String getEmailSmtpUser() {
		return emailSmtpUser;
	}
	public void setEmailSmtpUser(String emailSmtpUser) {
		this.emailSmtpUser = emailSmtpUser;
	}
	public String getEmailSmtpPwd() {
		return emailSmtpPwd;
	}
	public void setEmailSmtpPwd(String emailSmtpPwd) {
		this.emailSmtpPwd = emailSmtpPwd;
	}
	public String getEmailContentType() {
		return emailContentType;
	}
	public void setEmailContentType(String emailContentType) {
		this.emailContentType = emailContentType;
	}
	public String getEmailContentCharset() {
		return emailContentCharset;
	}
	public void setEmailContentCharset(String emailContentCharset) {
		this.emailContentCharset = emailContentCharset;
	}
	
	public String getDefaultToAddress() {
		return defaultToAddress;
	}

	public void setDefaultToAddress(String defaultToAddress) {
		this.defaultToAddress = defaultToAddress;
	}

	public String getSendAddress() {
		return sendAddress;
	}

	public void setSendAddress(String sendAddress) {
		this.sendAddress = sendAddress;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("EmailMessageProperties [emailServerSwitch=");
		builder.append(emailServerSwitch);
		builder.append(", emailSmtpServer=");
		builder.append(emailSmtpServer);
		builder.append(", emailSmtpUser=");
		builder.append(emailSmtpUser);
		builder.append(", emailSmtpPwd=");
		builder.append(emailSmtpPwd);
		builder.append(", emailContentType=");
		builder.append(emailContentType);
		builder.append(", emailContentCharset=");
		builder.append(emailContentCharset);
		builder.append(", defaultToAddress=");
		builder.append(defaultToAddress);
		builder.append(", sendAddress=");
		builder.append(sendAddress);
		builder.append("]");
		return builder.toString();
	}
	

}
